<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="shoppingCart" class="com.optimus.model.ShoppingCartBean" scope="session"></jsp:useBean>
<%@page import="java.util.List, java.lang.Integer"%>
<%@page import="com.optimus.model.mapped.ProductBean,
	com.optimus.dao.ProductDAO,
	com.optimus.dao.ProductDAOImpl,
	com.optimus.utils.SpringUtils"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta name="description" content="Smart Cart - a javascript shopping cart control for jQuery" />

	<!--<script type="text/javascript" src="js/ShoppingCartJS/jquery-1.3.2.min.js"></script> -->
	<script type="text/javascript" src="js/ShoppingCartJS/jquery-ui-1.7.2.custom.min.js"></script>
	<script type="text/javascript" src="js/ShoppingCartJS/jquery.scrollTo-min.js"></script>
	<script type="text/javascript" src="js/ShoppingCartJS/SmartCart.js"></script>

	<script type="text/javascript">

		$(document).ready(function() {
		  // call the cart function
			$("#sc_cart").smartCart();
		}); 
	</script>

	<link rel="stylesheet" type="text/css" href="css/ShoppingCartCSS/style_smartcart.css" />
</head>
<body>
<%
	if((request.getParameter("action") != null)&&(request.getParameter("action").equals("remove")))
	{
		ProductDAO productDAO = (ProductDAO) SpringUtils.getBean("productDAO");
		ProductBean product = productDAO.selectEntityFromDbById(Integer.valueOf(request
				.getParameter("id")));
		shoppingCart.removeProductFromCart(product);		
	}
	List<ProductBean> productList = shoppingCart.getProductsList();
	
%>
          <!-- Cart HTML -->
          <div id="sc_cart" class="scCart" align="center">
          <label><b>Shopping Cart</b></label><p/>
              <!-- Selected Product ID/Quantity are stored on the <select> element below -->
              <select id="product_list" name="product_list[]" style="display:none;" multiple="multiple">
              </select>               
               	<div class="scCartListHead">
                   <table width='100%' align="center">
                   <tr align="center">
                     <td>&nbsp;&nbsp;Product</td>
                     <td>Quantity</td>
                     <td>Price ($)</td>
                   </tr></table>
            	 </div>
               <div id="sc_cartlist">
	               <table>		               	
		               	<%
		               	if(productList != null)
		               	{
			               	for(ProductBean product : productList)
			               	{
			               		out.print("<tr align=\"center\">");
			               		out.print("<td width=\"100px\">" + product.getName() + "</td>");
			               		out.print("<td width=\"100px\">" + product.getShoppingCartQuantity() + "</td>");
			               		out.print("<td width=\"100px\">" + product.getPrice() + "</td>");
			               		out.print("<td>");
			        			out.print("<form action=\"productPage.jsp\" method=\"post\">");
			        			out.print("<input type=\"hidden\" name=\"id\" value=\""+product.getId()+"\"");
			        			out.print("<input type=\"hidden\" name=\"action\" value=\"remove\"");
			        			out.print("<input type=\"image\" src=\"images/ShoppingCartImages/delete_icon.png\" width=\"20\" height=\"20\" value=\"Remove\"/>");
			        			out.print("</form>");
			        			out.print("</td>");
			               		out.print("</tr>");
			               	}
		               	}
		               	%>	               		
               		</table>
               </div>
               <div class="scCartListHead">
                   <table width='100%'><tr>
                     <td>
                        <!-- Message Label -->
                        <span id="sc_message"></span></td>
                     <td width='100px'>Total ($):</td>
                     <td width='120px'> 
                        <!-- Sub Total Label -->
                        <span><jsp:getProperty property="totalPrice" name="shoppingCart"/> </span>
                     </td>
                   </tr></table>
            	 </div>
               <br>
               <form action="checkout.jsp" method="post"> 
               	 <input type="hidden" name="price" value="80"/>
            	 <input style="width:200px;height:35px;float:right;" type="submit" class="scBtn" value="Checkout >>">
            	</form>
          </div>
          <!-- End Cart HTML -->
	
     

</body>
</html>
